﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;

/// <summary>
/// Summary description for BasePage
/// </summary>
public class BasePage : System.Web.UI.Page
{
    /// <summary>
    /// Tạo một url để rewrite
    /// </summary>
    /// <param name="url"></param>
    /// <returns>Địa chỉ dùng để rewrite</returns>
    public string constructUrl(string url)
    {
        //string urlPrefix = (ConfigurationSettings.AppSettings["UrlPrefix"] != null) ? ConfigurationSettings.AppSettings["UrlPrefix"] : ".aspx";
        string urlPrefix = (ConfigurationManager.AppSettings["UrlPrefix"] != null) ? ConfigurationManager.AppSettings["UrlPrefix"] : ".aspx";
        return ContextPath + url + urlPrefix;
    }

    public string constructUrl(string url, bool ignorePrefix)
    {
        if (ignorePrefix)
        {
            return ContextPath + url;
        }
        else
        {
            return constructUrl(url);
        }
    }

    public string ContextPath
    {
        get
        {
            return (ConfigurationManager.AppSettings["ContextPath"] != null) ? ConfigurationManager.AppSettings["ContextPath"] : "/";
        }
    }
    protected override void InitializeCulture()
    {
        this.Culture = "vi-VN";
        this.UICulture = "vi-VN";
    }

}